package com.hxut.conifg;

import com.hxut.handler.MrsFailureHandler;
import com.hxut.handler.MrsSuccessHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.PortResolverImpl;

/**
 * description: SecurityConfig
 * date: 2022/7/9 22:43
 * author: MR.孙
 */
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    private MrsSuccessHandler successHandler;

    @Autowired
    private MrsFailureHandler failureHandler;

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.formLogin()
                //认证成功处理器
                .successHandler(successHandler)
                //认证失败处理器
                .failureHandler(failureHandler);



        http.authorizeRequests().anyRequest().authenticated();
    }
}
